<html>
<head>
	<title><?php echo $title?></title>
	<link rel="stylesheet" type="text/css" href="<?php echo base_url()?>assets/grocery_crud/css/font-awesome.min.css">
	<script type="text/javascript" src="<?php echo base_url()?>assets/grocery_crud/js/jquery-1.10.2.min.js"></script>
	<style type="text/css">
		table th,table td{
			font-family: tahoma;
			font-size: 12px;
		}
		tr.h th{
			background: #cecece;
		}
		tr.jml th{
			background: #dedede;
		}
		.backButton{
	background: none repeat scroll 0 0 #FEFEFE;
    border: 1px solid #DEDEDE;
    color: #666666;
    margin: 14px 0 0 9px;
    padding: 6px;
    position: absolute;
    text-decoration: none;
}
	</style>
</head>
<body>
<?php
$cap_series = ($ctrl=='volume'?'Jumlah Volume':($ctrl=='nilai'?'Nilai Impor (USD)':'Pengapalan Per Bulan'));
	
?>

<div align="center">	

<table align="center" border="2" cellpadding="2" colspacing="2" style="border-collapse:collapse">
<tr>
	<td align="left" colspan="<?php echo (count($data['series']) + 4)?>">
		<?php if(!isset($process_excel)):?>

	<a class="backButton" href="<?php echo $form_action?>"><i class="fa fa-reply"></i>&nbsp;Kembali</a>

<?php endif?>
		<div align="center"  style="min-width:680px">
<h3><?php echo $title?></h3>
		<span><?php echo $subtitle ?></span>
		</div>
		
	</td>
</tr>
<tr class="h">
	<th nowrap rowspan="2"><?php echo isset($limit_caption) ? 'Perusahaan':'Negara'?></th>
	<th nowrap colspan="2">HS Sesuai</th>
	<th nowrap colspan="<?php echo count($data['series'])?>"><?php echo $cap_series ?></th>
	<th nowrap rowspan="2">Jumlah</th>
</tr>	
<tr class="h">
	<th nowrap>No</th>
	<th nowrap>Kode HS</th>
	<?php foreach($data['series'] as $date):?>
	<th nowrap><?php echo strtoupper(date('M',strtotime($date.'-01')))?></th>
	<?php endforeach?>
</tr>
<?php foreach($data['record'] as $negara_muat => $r):?>
<?php $i = 1?>
	<?php $jml_bth = array() ?>
	<?php foreach($r as $k => $v):?>
	
	<?php if($k == 'total') continue; ?>

	<tr>
		<td nowrap><?php echo $i+1 == 2 ? $negara_muat : '&nbsp'?></td>
		<td nowrap align="center"><?php echo $i++ ?></td>
		<td nowrap style="color:#000"><?php echo $k ?></td>
		<?php $jml = 0;?>
		<?php foreach($data['series'] as $bln): ?>
		<?php $jml_bth_curr = $v[$bln] ? $v[$bln] : 0 ?>
		<?php $jml += $jml_bth_curr ?>
		<?php
			if(!isset($jml_bth[$bln]))
				$jml_bth[$bln] = 0;
			$jml_bth[$bln] += $jml_bth_curr;
		?>
		<?php //print_r($jml_bth) ?>
		<td nowrap align="<?php echo $ctrl=='nilai'?'right':'center'?>"><?php echo $ctrl=='nilai'?number_format($jml_bth_curr,2):$jml_bth_curr ?></td>
		<?php endforeach;?>
		<td nowrap align="<?php echo $ctrl=='nilai'?'right':'center'?>"><b><?php echo $ctrl=='nilai'?number_format($jml,2):$jml?></b></td>
	</tr>

	<?php endforeach;?>
	<tr class="jml">
		<th colspan="3" align="left">Jumlah <?php echo $negara_muat?></th>
		<?php foreach($jml_bth as $jml_tot): ?>
		<th nowrap align="<?php echo $ctrl=='nilai'?'right':'center'?>"><?php echo $ctrl=='nilai'?number_format($jml_tot,2):$jml_tot ?></th>
		<?php endforeach ?>
		<th align="<?php echo $ctrl=='nilai'?'right':'center'?>"><?php echo $ctrl=='nilai'?number_format($r['total'],2):$r['total'] ?></th>
	</tr>
<?php endforeach;?>
</table>
<?php if(!isset($process_excel)):?>
<form action="<?php echo $excel_action?>?doExcel=yes" style="padding 2em;margin:0 auto;text-align:center">
		<input type="hidden" name="doExcel" value="yes"/>
		<input type="hidden" name="doPrint" value="yes"/>
		<br/>
		<input type="submit" value="Expor Ke Excel" style="cursor:pointer"/>
	</form>
<?php endif ?>
</div>
</body>
</html>
<?php if(!isset($process_excel)):?>
<script type="text/javascript">
$(document).ready(function (argument) {
	$('.backButton').click(function(){
		history.back();
		return false;	
	})
})
</script>
<?php endif ?>